//@ts-nocheck
/*
使用react-redux帮我们完成redux的订阅
*/
import React from 'react';
import actions from '../store/actions/counter1';
import {CombinedState} from '../store/reducers';
import {Counter1State} from '../store/reducers/counter1';
import {connect} from '../react-redux';
type Props = Counter1State & typeof actions;
class Counter1 extends React.Component<Props> {
  constructor(props) {
    super(props);
    console.log('props:',props)
  }
  render() {
    console.log('Counter1 this.props.xxx:',this.props.xxx)
    return (
      <div>
        <p>{this.props.number}</p>
        <button onClick={this.props.increment}>+</button>
        <button onClick={this.props.decrement}>-</button>
      </div>
    )
  }
}

//仓库中的状态对象映射为当前组件的属性对象 state.counter1 将会成为当前组件props
const mapStateToProps = (state: CombinedState) => state.counter1;
//把actions映射为为当前组件props
// const mapDispatchToProps;
export default connect(
  mapStateToProps,
  actions
)(Counter1)
